package util;

public class Point {
	private double x;
	private double y;
	
	public Point(Point p) {
		this(p.x, p.y);
	}
	
	public Point(double x, double y) {
		this.x = x;
		this.y = y;
	}
	
	public double getX() {
		return x;
	}
	public double getY() {
		return y;
	}
	
	public double getMag() {
		return Math.sqrt(Math.pow(x,2) + Math.pow(y,2));
	}
	
	public double getAngle() {
		return Math.atan2(y,x);
	}
	
	public double distance(Point p) {
		return Math.sqrt(Math.pow(x - p.getX(), 2) + Math.pow(y - p.getY(), 2));
	}
	
	public String toString() {
		return "[" + x + ", " + y + "]";
	}
	
	public Point translate(double x, double y) {
		return new Point(x + this.x, y+ this.y);
	}
	
	public Point rotate(double angle) {
		return new Point((x * Math.cos(angle) + y * -Math.sin(angle)), (x * Math.sin(angle) + y * Math.cos(angle)));
	}
	
}
